package com.hengxinguotong.hxgtwygsp.ui.app;

import android.app.Application;
import android.content.Context;

import com.google.gson.Gson;
import com.hengxinguotong.hxgtwygsp.net.HttpRequest;
import com.hengxinguotong.hxgtwygsp.utils.PreferencesUtil;
import com.hengxinguotong.hxgtwygsp.utils.UserUtil;

import javax.inject.Singleton;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;

/**
 * TODO
 *
 * @author hjz
 * @version V1.0.0
 * @since 2018/12/22 11:32
 */

@Module
public abstract class AppModule
{
    /**
     * 将应用程序作为上下文绑定
     *
     * @param application
     * @return android.content.Context
     * @author hjz
     * @since 2018/12/22 13:10
     */
    @Binds
    abstract Context bindContext(Application application);

    /**
     * 提供用户数据处理工具对象
     *
     * @param preferencesUtil
     * @param gson
     * @return com.hengxinguotong.hxgtwyglj.utils.UserUtil
     * @author hjz
     * @since 2018/12/22 16:22
     */
    @Singleton
    @Provides
    static UserUtil providesUserUtil(PreferencesUtil preferencesUtil, Gson gson)
    {
        return new UserUtil(preferencesUtil, gson);
    }

    /**
     * 提供HttpRequest请求对象
     *
     * @param preferencesUtil
     * @param gson
     * @return com.hengxinguotong.hxgtwyglj.net.HttpRequest
     * @author hjz
     * @since 2018/12/22 13:31
     */
    @Singleton
    @Provides
    static HttpRequest providesHttpRequest(PreferencesUtil preferencesUtil, Gson gson)
    {
        return new HttpRequest(preferencesUtil, gson);
    }
}
